|
The nested set model is a particular technique for representing nested sets (also known as trees or hierarchies) in relational databases. The term was apparently introduced by Joe Celko; others describe the same technique without naming it 〔(''Recursive Hierarchies: The Relational Taboo!'' ), by Michael J. Kamfonas, in: ''The Relational Journal'' - October/November 1992,〕 or using different terms.〔(Storing Hierarchical Data in a Database: ''Modified Pre-order Tree Traversal'' ), by Gijs van Tulder, at articles.sitepoint.com〕 == Motivation == The technique is an answer to the problem that the standard relational algebra and relational calculus, and the SQL operations based on them, are unable to express all desirable operations on hierarchies directly. A hierarchy can be expressed in terms of a parent-child relation - Celko calls this the adjacency list model - but if it can have arbitrary depth, this does not allow the expression of operations such as comparing the contents of hierarchies of two elements, or determining whether an element is somewhere in the subhierarchy of another element. When the hierarchy is of fixed or bounded depth, the operations are possible, but expensive, due to the necessity of performing one relational join per level. This is often known as the bill of materials problem. Hierarchies may be expressed easily by switching to a graph database. Alternatively, several resolutions exist for the relational model and are available as a workaround in some relational database management systems: * support for a dedicated hierarchy data type, such as in SQL's hierarchical query facility; * extending the relational language with hierarchy manipulations, such as in the nested relational algebra. * extending the relational language with transitive closure, such as SQL's CONNECT statement; this allows a parent-child relation to be used, but execution remains expensive; * the queries can be expressed in a language that supports iteration and is wrapped around the relational operations, such as PL/SQL, T-SQL or a general-purpose programming language When these solutions are not available or not feasible, another approach must be taken. 抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)』 ■ウィキペディアで「Nested set model」の詳細全文を読む スポンサード リンク
|